package yang.zip;

import java.io.IOException;
import java.io.InputStream;

public class MyReader {
	private InputStream in;

	public MyReader(InputStream in) {
		this.in = in;
	}
	public int readInt() throws IOException{
		int a = in.read();
		int b = in.read();
		int c = in.read();
		int d = in.read();
		
		return a | b <<8 | c<<16 | d<<24;
	}
	public int readShort() throws IOException{
		int a = in.read();
		int b = in.read();
		
		return a | b <<8;
	}
	public byte[] readBytes(int n) throws IOException{
		if (n == 0)return null;
		byte[] a  = new byte[n];
		in.read(a);
		return a;
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
	}
	public static  String arrayToString(byte[] a){
		if(a == null)return "null";
		StringBuffer sb =new StringBuffer();
		sb.append(String.format("len is %x [",a.length));
		for(int i=0;i<a.length;i++){
			sb.append(String.format("%02x ", a[i]));
		}
		sb.append(" ]");
		return sb.toString();
	}
}
